package com.t123.mapper;

import com.t123.entity.User;
import org.apache.ibatis.annotations.*;


import java.util.List;

@Mapper
public interface UserMapper {

    //需要配置application.yml 中mybatis:mapper-locations 配置   classpath:mapper/*Mapper.xml
    //@Select("select * from user")
    List<User> getUsers ();

    @Select("select * from user where id=#{id}")
    User getUserById(Long id);

    @Insert("INSERT INTO `mybatis`.`user`(`id`, `name`, `age`, `email`)value (null ,#{name},#{age},#{email})")
    int addUser(User user);

    @Update("UPDATE `mybatis`.`user` SET `name` = #{name} , `age` = #{age} , `email` = #{email}  WHERE `id` = #{id} ")
    int updateUser(User user);

    @Delete("delete from user id=#{id} ")
    int deleteUser(Long id);
}
